
/**
 *  迪米特原则：
 *  
 * CEO通知销售经理，销售经理会通知每个销售
 * 
 * CEO和每个销售之间是相互隔离的
 * 
 */

// 销售
class Salesman {
    constructor(public name: string) {

    }
    sale() {
        console.log(this.name + ' 销售中....');
    }
}

// 销售经理
class SaleManager {
    private salesmen: Array<Salesman> = [new Salesman('张三'), new Salesman('李四')];
    sale() {
        this.salesmen.forEach(salesman => salesman.sale());
    }
}

class CEO {
    private saleManager: SaleManager = new SaleManager();
    sale() {
        this.saleManager.sale();
    }
}
let ceo = new CEO();
ceo.sale();